<template>
	<view>
		<view class="top-tab">
			<u-tabs :list="tab" gutter="200" :is-scroll="false" active-color="#111" :bar-style="{backgroundColor:'#de1f1c'}" inactive-color="#333" :current="current" @change="change"></u-tabs>
		</view>
		<view class="list">
			<view class="more-item u-flex" v-for="item in list" :key="item.id">
				<view class="image">
					<u-image width="206" height="160" border-radius="18" :src="imgUrl(item.images)"></u-image>
				</view>
				<view class="info u-flex-1">
					<view class="title u-flex">
						<view class="name u-flex-1 u-ellipsis">{{item.name}}</view>
						<view class="label">
							<text v-if="item.is_selected_switch">精选</text>
						</view>
					</view>
					<view class="position u-ellipsis" style="height: 32rpx;">{{item.title}}</view>
					<view class="label-list u-ellipsis" style="height: 40rpx;">
						<text v-for="f in item.housebaseset_features" :key="f.id">{{f.name}}</text>
						<!-- <view class="iconfont icon-xiajia" v-show="current == 0"></view> -->
						<!-- <view class="iconfont icon-shangjia" v-show="current == 1"></view> -->
						<!-- <view class="iconfont icon-bianji" v-show="current == 1"></view> -->
					</view>
					<view class="price-box u-flex">
						<view class="price">{{Number(item.totalprice)}}元/月</view>
						<view class="text">{{item.housebaseset_housetype[0].name}}</view>
					</view>
				</view>
			</view>
		</view>
		
		<u-empty v-if="isEmpty" text="暂无相关信息" margin-top="200"></u-empty>
		<!-- 底部安全区适配 -->
		<view class="safe-area-inset-bottom"></view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				tab: [{
					name: '已上架'
				}, {
					name: '未上架'
				}],
				list:'',
				isEmpty:!0,
				current: 0
			}
		},
		methods: {
			change(index) {
				this.current = index
				this.list = ''
				this.getList()
			},
			getList(){
				this.$u.post('/api/agent/getRentHouse',{
					switch:this.current === 0 ? 1 : ''
				}).then(res=>{
					this.list = res
					if(res.length === 0){
						this.isEmpty = !0
					}
				})
			}
		},
		onLoad(){
			this.getList()
		}
	}
</script>

<style lang="scss">
	page{background-color: #f8f8f8;}
	.top-tab{border-bottom: 1rpx solid #ddd;position: sticky;top: 0;z-index: 9;}
	.more-item{
		padding: 30rpx;background-color: #fff;margin-top: 18rpx;
		&:first-child{margin-top: 0;}
		.image{
			image{width: 206rpx;height: 160rpx;border-radius: 20rpx;display: block;}
		}
		.info{
			margin-left: 20rpx;overflow: hidden;
			.title{
				.name{font-size: 30rpx;
						font-weight: bold;
						// line-height: 30rpx;
				  //   max-height: 60rpx;
				  //   overflow: hidden;
				  //   display: -webkit-box;
				  //   -webkit-line-clamp: 2;
				  //   -webkit-box-orient: vertical
				}
				.label{align-self: flex-start;
					text{background-color: $tc;color: #fff;font-size: 24rpx;padding: 2rpx 8rpx;border-radius: 6rpx;margin: 0 6rpx;}
					.wait{background-color: #999;}
				}
			}
			.position{font-size: 24rpx;color: #666;}
			.label-list{white-space: nowrap;position: relative;padding-right: 80rpx;color: #ffa100;
				text{color: #ffa100;font-size: 26rpx;margin-right: 20rpx;
					&:last-child{margin-right: 0;}
				}
				// 已上架时 显示下架按钮
				.icon-xiajia{position: absolute;right: 6rpx;top: 0;font-size: 40rpx;color: #aaa;}
				// 已下架时 显示编辑 上架 按钮
				.icon-shangjia{position: absolute;right: 6rpx;top: 0;font-size: 40rpx;color: #1480f9;}
				.icon-bianji{position: absolute;right: 50rpx;top: -1rpx;font-size: 42rpx;color: #aaa;}
			}
			.price-box{
				.price{color: #f00;font-size: 30rpx;font-weight: bold;}
				.text{margin-left: 30rpx;font-size: 26rpx;color: #666;}
			}
		}
	}
</style>
